Random variables overview
You can create random numeric and text (string) variables in the variable definitions table below the Description.
After clicking add varDefinition, click add @varType to indicate the Type as numeric or string, and provide variable specifics.
The following table provides basic information pertaining to:
- Both numeric and text variables
- Numeric variables only
- Text variables only
All variables (text and numeric) |
|
Numeric variables |
|
Text variables |
|
Value Lists
For text variables, the Mastering system doesn't generate random values as it does for numeric variables when you enter Min/Max/Step values. Instead, you enter a set of words or letters, called a Value List, for each text variable. The system randomly displays one of the values in the list each time a student views the item.
You must supply a numeric ID for each Value List. To associate lists with related values, use the same ID. This is useful to:
- Associate a word or one or more letters with a numeric
- Display a variable differently, depending on its location in the item
Associating text with a numeric
The example below associates the four elements (bromine, aluminum, calcium, and sodium) with their respective atomic weights by assigning an ID of 2 to both lists. To correctly associate values, code each value set in the same order in each list (values in the first cell of each list are associated, values in the second cell of each list are associated, and so on).
Displaying a variable differently, depending on its location
You may want to include the same variable in a Part (using TeX) and in a solutionChemicalFormula answer (using Chem TeX, required). To do this, define each variable separately, but enter the same ID for both. In the following example, whenever the system randomly chooses Na^+, it uses Na{^{+}} for the answer.
Note: If you temporarily turn off randomization to check your work (Action > Standard View Non-Randomized or Action > Solution View Non-Randomized), only the first value in each list displays wherever the variable appears in the item.
Using variables with answer types
You can add variables to answer boxes, as described in this section.
Numeric variables
You can use numeric variables for the same answer types as text variables However, most of the time you'll add numeric variables to solutionSymbolic and solutionSymbolicSet answer boxes. Do not use colons before or after the variable.
Text variables
You can add text variables to answer boxes for the following answer types:
Answer types | Requirements |
solutionMultipleChoiceRadio solutionMultipleChoiceDropdown solutionMultipleChoiceSelect |
Code answers using the var tag. Make sure that each correct answer iteration has the same ID and Option. You can’t randomize which choice is correct, only which values display. |
solutionSymbolic solutionSymbolicSet |
You can only enter one text variable per answer. Don’t enter colons before or after text or numeric variables. Colons are required only for chemical formula and text answer types. See Formatting for solutionChemicalFormula and solutionString Answer Types. |
solutionString solutionStringSet |
Code answers using unformatted text (no TeX or html formatting). Use colons before and after each variable. |
solutionChemical solutionChemicalSet |
Code answers with text variables using Chem TeX. Use colons before and after each variable. |
solutionAppletRanking solutionAppletSorting solutionAppletVocabulary solutionAppletLabel |
Code answers using the var tag. You can use unformatted text (no TeX or html formatting). For ranking and sorting, you can include images in the Value List and code them using a var tag and htmlText. For each correct answer variation, be aware that you can't randomize which choice is correct, only which values display. For example, for every variation of a vocabulary task, the same text variable appears in the same place. Each value for the variable must be correct within the sentence. See the following section for a sorting example. |
Sorting example
Note that the Item IDs for the variables:
- M for metal, Item ID 1
- N for nonmetal, Item ID 2
- S for semimetal, Item ID 3
Match the Bin IDs for the correct elements. When coding, you must ensure that the Value List for each category contains every item for that category. In this example, the Value List for:
- M contains all metals
- N contains all nonmetals
- S contains all semimetals
as shown below.
Formatting for solutionChemicalFormula and solutionString Answer Types
Use a colon before and after both numeric and text variables in all solutionChemicalFormula and solutionString answer types. For example, code the variable F_2 in the solutionChemicalFormula answer type as:
For symbolic answer types, colons aren't needed.
See also:
Defining randomized variables with other variables
Functions for specifying randomly generated values